from workflow import NovelWorkflow
from util import write_file
import logging

logging.basicConfig(level=logging.INFO)

if __name__ == "__main__":
    workflow = NovelWorkflow()
    app = workflow.compile_workflow()
    
    # 执行工作流并设置递归限制
    result_state = app.invoke({
        "current_outline": "",
        "chapters": {},
        "iteration_count": 0
    }, {"recursion_limit": 5})
    
    # 保存生成内容
    write_file('output/outline.txt', result_state['current_outline'])
    
    # 保存各章节内容
    for chapter_name, content in result_state['chapters'].items():
        write_file(f'output/chapters/{chapter_name}.txt', content)